//
//  dpCell.m
//  decision
//
//  Created by Zhiguo on 03.02.10.
//  Copyright 2010 Home. All rights reserved.
//

#import "dpCell.h"

@interface dpCell()

-(UILabel *)newLabelWithPrimaryColor:(UIColor *)primaryColor selectedColor:(UIColor *)selectedColor fontSize:(CGFloat)fontSize blod:(BOOL)bold;

@end


@implementation dpCell
@synthesize dpTextLabel,dp;

- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
    if (self == [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
		//NSLog(@"[super initWithFrame:frame reuseIdentifier:reuseIdentifier]");
		UIView *myContentView = self.contentView;
		// Initialization code
    
	
	self.dpTextLabel = [self newLabelWithPrimaryColor:[UIColor blackColor] selectedColor:[UIColor whiteColor] fontSize:14.0 blod:YES];
	//self.dpTextLabel.textAlignment = UITextAlignmentLeft;
		[myContentView addSubview:self.dpTextLabel];
		[self.dpTextLabel release];
	}else{
		NSLog(@"!!!![super initWithFrame:frame reuseIdentifier:reuseIdentifier]");
	}
    return self;
}

- (void)layoutSubviews {
	[super layoutSubviews];
	CGRect contentRect = self.contentView.bounds;
	if(!self.editing){
		CGFloat boundsX = contentRect.origin.x;
		CGRect frame;
		frame = CGRectMake(boundsX+75, 4, 240,13);
		frame.origin.y = 15;
		self.dpTextLabel.frame = frame;
	}
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(decisionPoint *)dp{
	return self.dp;
}

-(void)setdp:(decisionPoint *)newDp {
	dp = newDp;
	self.dpTextLabel.text = newDp.truncate;
}

-(UILabel *)newLabelWithPrimaryColor:(UIColor *)primaryColor 
					   selectedColor:(UIColor *)selectedColor fontSize:(CGFloat)fontSize blod:(BOOL)bold {
	UIFont *font;
	if(bold){
		font = [UIFont boldSystemFontOfSize:fontSize];
		
	}else {
		font = [UIFont systemFontOfSize:fontSize];
	}
	UILabel *newLabel = [[UILabel alloc] initWithFrame:CGRectZero];
	newLabel.backgroundColor = [UIColor whiteColor];
	newLabel.opaque = YES;
	newLabel.textColor = primaryColor;
	newLabel.highlightedTextColor = selectedColor;
	newLabel.font = font;
	
	return newLabel;

}
- (void)dealloc {
    [super dealloc];
}


@end
